2025-11-02 Using jujutsu in a git compatible way to track freebsd ports
A JJ crash primer
If you've not heard of jujutsu it is a version control system (VCS) or source code management (SCM) system that also can work with git. I am going to assume the reader is familiar with the basics of git and what one would use it for.
FreeBSD has switched (as of 2020) to using git as the primary VCS for many of its projects (ex. base and docs). This has been a welcome update as this means tools a typical dev (in 2025) would use (git) can now be used with FreeBSD. While tools aren't everything, they can make a difference between noping out from contributing or not.
Jujutsu has the ability to use different types of backends for how it stores the repository. However, the real killer feature is that it also includes a git backend. This allows jujutsu to work on top and co-exist with a git repo.
Other VCSes such as mercurial or fossil have their own backend and require some form of conversion to access a git repo. One unfortunate consequence of a separate backend from git is that interacting with software projects that use git means more than just a one-time conversion (aka migration) for a user of something like mercurial or fossil. It would require some way to continuously keep up with changes for a software project which would mean the conversion process from git and back to git would need to be continuous. This is unfortunately a (much) harder problem than a one-time migration. Tooling for this is quite under-represented and more likely a DIY type of situation.
This is where jujutsu's git compatibility feature really shines. In this case, since git is now powering FreeBSD source code it's now possible to try out jujutsu to track FreeBSD code (which I have been quietly experimenting on for the past couple of months).
So here comes a getting started guide (for tracking FreeBSD ports). Hopefully, better guides might come available as practices around using jujutsu to track git-backed projects become more understood.
Just show me the steps
First, get jujutsu and git for FreeBSD (package instructions below). I use the lite flavor of git to minimize the amount of git dependencies.
$ doas pkg install jujutsu
$ doas pkg install git-lite
Next, clone the ports repo with git and track the main branch.
$ cd /usr/ports
$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
Finally, setup jj as a colocated repo with the git checkout
$ jj git init --colocate .
Done importing changes from the underlying Git repo.
Setting the revset alias `trunk()` to `main@origin`
Hint: The following remote bookmarks aren't associated with the existing local bookmarks:
main@origin
Hint: Run the following command to keep local bookmarks updated on future pulls:
jj bookmark track main@origin
Initialized repo in "."
Congrats you can now use jj git fetch or git fetch to keep up to date. While it might be possible to use only jujutsu without git, my current take is that it might be a little early to completely drop git.